package com.mindbook.vip.gawxchatinfo.utils;

/**
 * @NAME: wxb
 * @DATE: 2022/8/5
 * @DESCRIPTION:
 **/
public class IntToRomanUtils {

    /**
     * 将数字转化为罗马数字
     * @param num
     * @return
     */
    public static String intToRoman(int num) {
        int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String[] symbols = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
        StringBuffer ss = new StringBuffer();

        for (int i = 0; i < values.length; i++) {
            while (num >= values[i]) {
                num = num - values[i];
                ss.append(symbols[i]);
            }
            if (num == 0) {
                return ss.toString();
            }
        }
        return ss.toString();
    }
}
